package com.cdy.server.netty;

import com.cdy.common.command.Command;
import com.cdy.server.handler.CommandHandler;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * netty处理器
 * <p>
 * Created by 陈东一
 * 2019/10/19 0019 21:27
 */
@Slf4j
@ChannelHandler.Sharable
public class ServerHandler extends SimpleChannelInboundHandler<Command> {
    
    private CommandHandler commandHandler;
    
    public ServerHandler(CommandHandler commandHandler) {
        this.commandHandler = commandHandler;
    }
    
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Command msg) throws Exception {
        commandHandler.handle(ctx, msg);
    }

}
